from django.contrib import admin
from .models import Artwork


@admin.register(Artwork)
class ArtworkAdmin(admin.ModelAdmin):
    """作品管理"""
    list_display = ['id', 'title', 'type', 'user', 'style', 'view_count', 'like_count', 'comment_count', 'is_public', 'created_at']
    list_filter = ['type', 'is_public', 'created_at']
    search_fields = ['title', 'description', 'user__username']
    readonly_fields = ['view_count', 'like_count', 'comment_count', 'created_at', 'updated_at']
    list_per_page = 20
    date_hierarchy = 'created_at'
    
    fieldsets = [
        ('基本信息', {
            'fields': ['user', 'type', 'title', 'description']
        }),
        ('作品内容', {
            'fields': ['content', 'style', 'parameters']
        }),
        ('统计数据', {
            'fields': ['view_count', 'like_count', 'comment_count', 'is_public']
        }),
        ('时间信息', {
            'fields': ['created_at', 'updated_at']
        }),
    ]
